<?php session_start();?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<?php
if(isset($_SESSION['lang']))
    require_once "./language_files/viewNewMessages_" . $_SESSION['lang'] . ".php";
else
    require_once "./language_files/viewNewMessages_en.php";
require_once "functions.php";
function viewnewmessages($member_id)
{
    global $lang;
// opening the connection
    //getting the memberid
// retrieveing the message id
    $query1=mysql_query("
SELECT m.`message_id`
FROM  `messages`m INNER JOIN `member_message_member` mm ON m.`message_id`= mm.`message_id`
WHERE mm.`member_id2` = '$member_id' AND m.`seen`=0") or die(mysql_error());
//adding a count variable to know how many new messages he has
    $count=0;
// looping over the messages 
    while($row5=mysql_fetch_array($query1))
    {

        $count++;
    }
//adding a link to redirect him to the inbox
    if($count >= 1)
    {
        echo"
<td><a href='viewmessages.php'> " . $lang['text_1'] . " {$count} " . $lang['text_2'] . "</a></td>
</tr>";
    }
    else
    {
        return;
    }
}
?>


